2ad24745e5bac0fa316442abb2702b024e04f08b,Core/src/main/java/com/zhaoxiaodan/mirserver/network/encoder/ServerPacketBit6Encoder.java,ServerPacketBit6Encoder,encode,#ChannelHandlerContext#ByteBuf#List#,17
Before Change
}
byte[] body = new byte[in.readableBytes()];
in.readBytes(body);
buf.writeBytes(Bit6Coder.encoder6BitBuf(body));
}
After Change
in.readBytes(header);
buf.writeBytes(Bit6Coder.encoder6BitBuf(header));
if (protocol != null && protocol.lenghtOfSections != null && protocol.lenghtOfSections.length == 0) {
byte[] bodyBytes = new byte[in.readableBytes()];
in.readBytes(bodyBytes);
buf.writeBytes(bodyBytes);
}else if (protocol != null && protocol.lenghtOfSections != null) {
for (int lenght : protocol.lenghtOfSections) {
if (in.readableBytes() > lenght) {
byte[] bodyBytes = new byte[lenght];
in.readBytes(bodyBytes);
buf.writeBytes(Bit6Coder.encoder6BitBuf(bodyBytes));
} else {
break;
}
}
}else{
byte[] body = new byte[in.readableBytes()];
in.readBytes(body);
buf.writeBytes(Bit6Coder.encoder6BitBuf(body));
}
}